package com.hxm.recyclerviewandscrollview;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

/**
 * Created by hxm on 2017/9/18.
 * 描述：
 */
public class ScrollAdapter extends RecyclerView.Adapter<ScrollAdapter.ScrollHodler> {
    private List<String> items;

    public ScrollAdapter(List<String> items) {
        this.items = items;
    }

    @Override
    public ScrollHodler onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_scroll, parent, false);
        return new ScrollHodler(view);
    }

    @Override
    public void onBindViewHolder(ScrollHodler holder, int position) {
        holder.textView.setText(items.get(position));
        if (position % 2 == 0) {

        }
    }

    @Override
    public int getItemCount() {
        return items.size();
    }

    static class ScrollHodler extends RecyclerView.ViewHolder {
        private TextView textView;

        public ScrollHodler(View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.text);
        }
    }
}
